package com.example.javachatroomextend.mapper;

import com.example.javachatroomextend.model.Session;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface FriendMapper {
    @Select("select userId,username as friendName,image from user where userId in (select friendId from friend where userId=#{userId})")
    List<Session> getFriendList(@Param("userId") Integer userId);

    @Select("select userId from friend where userId=#{userId} and friendId=#{friendId}")
    Integer isFriends(@Param("userId") Integer userId,@Param("friendId") Integer friendId);

    @Insert("insert into friend values(#{userId},#{friendId})")
    Integer addFriend(@Param("userId") Integer userId,@Param("friendId") Integer friendId);
}
